#!/bin/bash

set -e -o pipefail

wget -q -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | \
    awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > \
    /tmp/chinadns_chnroute.txt

mv -f /tmp/chinadns_chnroute.txt ./chnroute.txt

logger -st "chnroute" "Update done"
